package io.acna.qiniu.core;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class IO {

	public static File readOrCreateFile(String filename) {
		File file = new File(filename);
		return file;
	}

	public static String readText(String filename) throws IOException {
		File file = readOrCreateFile(filename);
		BufferedReader br = new BufferedReader(new InputStreamReader(
				new FileInputStream(file)));
		StringBuffer sb = new StringBuffer();
		String line = null;
		while ((line = br.readLine()) != null) {
			sb.append(line);
		}
		if (br != null)
			br.close();
		return sb.toString();
	}
}
